package com.xyzyzglxt.web.controller.volunteer;

import java.util.List;
import javax.servlet.http.HttpServletResponse;


import com.xyzyzglxt.common.core.redis.RedisCache;
import com.xyzyzglxt.system.domain.SysUserEvent;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xyzyzglxt.common.annotation.Log;
import com.xyzyzglxt.common.core.controller.BaseController;
import com.xyzyzglxt.common.core.domain.AjaxResult;
import com.xyzyzglxt.common.enums.BusinessType;
import com.xyzyzglxt.common.core.domain.entity.SysEventType;
import com.xyzyzglxt.system.service.ISysEventTypeService;
import com.xyzyzglxt.common.utils.poi.ExcelUtil;
import com.xyzyzglxt.common.core.page.TableDataInfo;

/**
 * 【活动类型】Controller
 *
 * @author xyzyzglxt
 * @date 2022-01-28
 */
@RestController
@Api(tags = "活动类型")
@RequestMapping("/volunteer/type")
public class SysEventTypeController extends BaseController
{
    @Autowired
    private ISysEventTypeService sysEventTypeService;
    @Autowired
    private RedisCache redisCache;



    /**
     * 查询【活动类型】列表
     */
    @ApiOperation("查询")
    @PreAuthorize("@ss.hasPermi('volunteer:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysEventType sysEventType)
    {
        startPage();
        List<SysEventType> list = sysEventTypeService.selectSysEventTypeList(sysEventType);
        return getDataTable(list);
    }

    /**
     * 导出【活动类型】列表
     */
    @PreAuthorize("@ss.hasPermi('volunteer:type:export')")
    @ApiOperation("导出")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysEventType sysEventType)
    {
        List<SysEventType> list = sysEventTypeService.selectSysEventTypeList(sysEventType);
        ExcelUtil<SysEventType> util = new ExcelUtil<SysEventType>(SysEventType.class);
        util.exportExcel(response, list, "【活动类型】数据");
    }

    /**
     * 获取【活动类型】详细信息
     */
    @PreAuthorize("@ss.hasPermi('volunteer:type:query')")
    @ApiOperation("根据TypeId获取详细信息")
    @GetMapping(value = "/{typeId}")
    public AjaxResult getInfo(@PathVariable("typeId") Long typeId)
    {
        return AjaxResult.success(sysEventTypeService.selectSysEventTypeByTypeId(typeId));
    }

    /**
     * 新增【活动类型】
     */
    @ApiOperation("增加")
    @PreAuthorize("@ss.hasPermi('volunteer:type:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysEventType sysEventType)
    {
        return toAjax(sysEventTypeService.insertSysEventType(sysEventType));
    }

    /**
     * 修改【活动类型】
     */
    @ApiOperation("修改")
    @PreAuthorize("@ss.hasPermi('volunteer:type:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysEventType sysEventType)
    {
        return toAjax(sysEventTypeService.updateSysEventType(sysEventType));
    }

    /**
     * 删除【活动类型】
     */
    @ApiOperation("删除")
    @PreAuthorize("@ss.hasPermi('volunteer:type:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{typeIds}")
    public AjaxResult remove(@PathVariable Long[] typeIds)
    {
        return toAjax(sysEventTypeService.deleteSysEventTypeByTypeIds(typeIds));
    }
}
